package com.edu.exam.enums;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 会话事件操作结果枚举
 *
 * @author System
 * @version 1.0.0
 */
public enum SessionEventOperationResult implements BaseEnum {
    /** 成功 */
    SUCCESS("SUCCESS", "成功"),
    /** 失败 */
    FAILURE("FAILURE", "失败"),
    /** 部分成功 */
    PARTIAL_SUCCESS("PARTIAL_SUCCESS", "部分成功"),
    /** 超时 */
    TIMEOUT("TIMEOUT", "超时"),
    /** 取消 */
    CANCELLED("CANCELLED", "取消"),
    /** 跳过 */
    SKIPPED("SKIPPED", "跳过"),
    /** 重试 */
    RETRY("RETRY", "重试"),
    /** 未知 */
    UNKNOWN("UNKNOWN", "未知");

    private final String code;
    private final String description;

    SessionEventOperationResult(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public static SessionEventOperationResult fromCode(String code) {
        for (SessionEventOperationResult result : values()) {
            if (result.getCode().equals(code)) {
                return result;
            }
        }
        throw new IllegalArgumentException("未知的会话事件操作结果代码: " + code);
    }

    public static SessionEventOperationResult fromDescription(String description) {
        for (SessionEventOperationResult result : values()) {
            if (result.getDescription().equals(description)) {
                return result;
            }
        }
        throw new IllegalArgumentException("未知的会话事件操作结果描述: " + description);
    }

    @Override
    public String toString() {
        return description;
    }
}